package etxt2db.ucompare.query;

import java.util.ArrayList;
import java.util.List;

import etxt2db.api.ClassificationModel;
import etxt2db.api.ClassificationModelCreator;
import etxt2db.features.CharacterFeatureClassifier;

/**
 * Container of useful information to be returned from the parsing 
 * of a query from an E-txt2db specification.
 *
 */
public class QueryInformationObject {
	
	private int action = Etxt2DBGrammarParser.NOTHING;
	
	/**
	 * Returns the identifier of the action represented by the query.
	 */
	public int getAction() {
		return action;
	}
	
	/**
	 * Sets the identifier of the action represented by the query.
	 * 
	 * @param action the identifier to set
	 */
	public void setAction(int action) {
		this.action = action;
	}
	
	/**
	 * Getter for the {@link ClassificationModel} object returned from the training process.
	 */
	public ClassificationModel getTrainingResult() {
		return trainingResult;
	}
	
	/**
	 * Sets the {@link ClassificationModel} object returned from the training process.
	 * @param trainingResult the {@link ClassificationModel} object to set
	 */
	public void setTrainingResult(ClassificationModel trainingResult) {
		this.trainingResult = trainingResult;
	}
	
	/**
	 * Returns the list of named entity annotation types to be found.
	 */
	public List<String> getTypesList() {
		return typesList;
	}
	
	/**
	 * Sets the list of named entity annotation types.
	 * 
	 * @param typesList	the list to set
	 */
	public void setTypesList(List<String> typesList) {
		this.typesList = typesList;
	}
	
	/**
	 * Adds a single named entity annotation type to the list of types.
	 * 
	 * @param type	the type to add
	 */
	public void addType(String type) {
		this.typesList.add(type);
	}
	
	/**
	 * Returns the name of an E-txt2db annotator.
	 */
	public String getAnnotatorName() {
		return annotatorName;
	}
	
	/**
	 * Sets the name of an E-txt2db annotator.
	 * 
	 * @param annotatorName	the name to set
	 */
	public void setAnnotatorName(String annotatorName) {
		this.annotatorName = annotatorName;
	}
	
	/**
	 * Returns the name of the data location to be tested in the classification or evaluation process.
	 * 
	 * @return	the name of a file or directory
	 */
	public String getTestingFile() {
		return testingFile;
	}
	
	/**
	 * Sets the name of the data location to be tested in the classification or evaluation process.
	 * 
	 * @param testingFile the name of the file or directory to set
	 */
	public void setTestingFile(String testingFile) {
		this.testingFile = testingFile;
	}
	
	/**
	 * Returns the machine learning technique to be used in the training process.
	 * 
	 * @return the {@link ClassificationModelCreator.MLTechnique} enumeration element representing the technique
	 */
	public ClassificationModelCreator.MLTechnique getMachineLearningTechnique() {
		return machineLearningTechnique;
	}
	
	/**
	 * Sets the machine learning technique to be used in the training process.
	 * 
	 * @param machineLearningTechnique the {@link ClassificationModelCreator.MLTechnique} enumeration element to set
	 */
	public void setMachineLearningTechnique(ClassificationModelCreator.MLTechnique machineLearningTechnique) {
		this.machineLearningTechnique = machineLearningTechnique;
	}
	
	/**
	 * Returns the list of features to be captured in the training process.
	 */
	public List<CharacterFeatureClassifier> getFeaturesList() {
		return featuresList;
	}
	
	/**
	 * Sets the list of features to be captured in the training process.
	 * @param featuresList	the list to set
	 */
	public void setFeaturesList(List<CharacterFeatureClassifier> featuresList) {
		this.featuresList = featuresList;
	}
	
	/**
	 * Adds a feature to be captured in the training process.
	 * 
	 * @param feature the {@link CharacterFeatureClassifier} to add to the list
	 */
	public void addFeature(CharacterFeatureClassifier feature) {
		this.featuresList.add(feature);
	}
	
	/**
	 * Returns the list of UCompare input types to be captured as features.
	 */
	public List<String> getUCompareFeaturesList() {
		return UCompareFeaturesList;
	}
	
	/**
	 * Sets the list of UCompare input types.
	 * 
	 * @param UCompareFeaturesList	the list to set
	 */
	public void setUCompareFeaturesList(List<String> UCompareFeaturesList) {
		this.UCompareFeaturesList = UCompareFeaturesList;
	}
	
	/**
	 * Adds a UCompare input type.
	 * 
	 * @param type	the UCompare input type to add
	 */
	public void addUCompareFeature(String type) {
		this.UCompareFeaturesList.add(type);
	}
	
	/**
	 * Returns the radius of the window to be used in feature capturing.
	 */
	public int getFeaturesWindow() {
		return featuresWindow;
	}
	
	/**
	 * Sets the radius of the window to be used in feature capturing.
	 * 
	 * @param featuresWindow the radius to set
	 */
	public void setFeaturesWindow(int featuresWindow) {
		this.featuresWindow = featuresWindow;
	}
	
	public int getLine() {
		return line;
	}
	
	public void setLine(int line) {
		this.line = line;
	}
	
	public int getCharPositionInLine() {
		return charPositionInLine;
	}
	
	public void setCharPositionInLine(int charPositionInLine) {
		this.charPositionInLine = charPositionInLine;
	}
	
	/**
	 * Returns the constant identifying the technique to be used in the training process.
	 */
	public int getTechniqueUsed() {
		return techniqueUsed;
	}
	
	/**
	 * Sets the constant identifying the training technique.
	 * 
	 * @param techniqueUsed	the constant to set
	 */
	public void setTechniqueUsed(int techniqueUsed) {
		this.techniqueUsed = techniqueUsed;
	}
	
	/**
	 * Returns the name of the UCompare workflow file if specified in the query.
	 * 
	 * @return	the name of the UCompare workflow file or null if not specified in the query
	 */
	public String getWorkflowFile() {
		return workflowFile;
	}
	
	/**
	 * Sets the name of the UCompare workflow file specified in the query.
	 * @param workflowFile	the name of the UCompare workflow file to set
	 */
	public void setWorkflowFile(String workflowFile) {
		this.workflowFile = workflowFile;
	}
	
	/**
	 * Returns the constant identifying the context by which the documents are 
	 * supposed to be split.
	 */
	public int getContext() {
		return context;
	}
	
	/**
	 * Sets the constant identifying the context by which the documents are 
	 * supposed to be split, e.g. sentence, phrase, etc.
	 * 
	 * @param context	the constant identifying the splitting context of documents
	 */
	public void setContext(int context) {
		this.context = context;
	}
	
	/**
	 * Returns the name of the annotation type to be used as a tokenizer.
	 */
	public String getTokenizerName() {
		return tokenizerName;
	}
	
	/**
	 * Sets the name of the annotation type to set as the tokenizer.
	 * 
	 * @param tokenizerName	the name of the annotation type to set
	 */
	public void setTokenizerName(String tokenizerName) {
		this.tokenizerName = tokenizerName;
	}
	
	/**
	 * Returns the regular expression to use for the regular expression training technique.
	 */
	public String getRegularExpression() {
		return regularExpression;
	}
	
	/**
	 * Sets the regular expression to use for the regular expression training technique.
	 * 
	 * @param regularExpression	the regular expression to set
	 */
	public void setRegularExpression(String regularExpression) {
		this.regularExpression = regularExpression;
	}
	
	/**
	 * Returns the String with the name of the class that is matched by the regular expression.
	 */
	public String getRegularExpressionType() {
		return regularExpressionType;
	}
	
	/**
	 * Sets the String with the name of the class that is matched by the regular expression.
	 * 
	 * @param regularExpressionType	the String to set
	 */
	public void setRegularExpressionType(String regularExpressionType) {
		this.regularExpressionType = regularExpressionType;
	}
	
	/**
	 * Returns the path to the dictionary file to use for the dictionary training technique.
	 */
	public String getDictionaryPath() {
		return dictionaryPath;
	}
	
	/**
	 * Sets the path to the dictionary file to use for the dictionary training technique.
	 * 
	 * @param dictionaryPath the path to set
	 */
	public void setDictionaryPath(String dictionaryPath) {
		this.dictionaryPath = dictionaryPath;
	}
	
	/**
	 * States whether a dictionary is case sensitive.
	 * 
	 * @return	boolean value indicating whether a dictionary is case sensitive
	 */
	public boolean isDictionaryCase() {
		return dictionaryCase;
	}
	
	/**
	 * Sets whether a dictionary is case sensitive.
	 * 
	 * @param dictionaryCase boolean value to set
	 */
	public void setDictionaryCase(boolean dictionaryCase) {
		this.dictionaryCase = dictionaryCase;
	}
	
	/**
	 * Returns the path to a file containing a training corpus.
	 * 
	 * @return the path to a file containing a training corpus
	 */
	public String getMachineLearningTrainingPath() {
		return machineLearningTrainingPath;
	}
	
	/**
	 * Sets the path to the file containing a training corpus.
	 * 
	 * @param machineLearningTrainingPath the path to set
	 */
	public void setMachineLearningTrainingPath(String machineLearningTrainingPath) {
		this.machineLearningTrainingPath = machineLearningTrainingPath;
	}
	
	/**
	 * Returns the string of the beginning of a tag.
	 * 
	 * @return the string of the beginning of a tag
	 */
	public String getBeginTag() {
		return beginTag;
	}
	
	/**
	 * Sets the string of the beginning of a tag.
	 * 
	 * @param beginTag the string to set
	 */
	public void setBeginTag(String beginTag) {
		this.beginTag = beginTag;
	}
	
	
	/**
	 * Returns the string of the ending of a tag.
	 * 
	 * @return the string of the ending of a tag
	 */
	public String getEndTag() {
		return endTag;
	}
	
	/**
	 * Sets the string of the ending of a tag.
	 * 
	 * @param endTag the string to set
	 */
	public void setEndTag(String endTag) {
		this.endTag = endTag;
	}
	
	/**
	 * States whether the scope of documents is files or lines.
	 * 
	 * @return	true if the scope of documents is files, false if it is lines
	 */
	public boolean isDocPerFile() {
		return docPerFile;
	}
	
	/**
	 * Sets a boolean value indicating whether the scope of documents is files (true) or lines (false).
	 * 
	 * @param docPerFile the boolean value to set
	 */
	public void setDocPerFile(boolean docPerFile) {
		this.docPerFile = docPerFile;
	}
	
	/**
	 * Sets the list of annotators to be used in the classification model union 
	 * technique during a training process.
	 * 
	 * @param annotators the list of annotators to set
	 */
	public void setAnnotators(List<String> annotators) {
		this.annotators = annotators;
	}
	
	/**
	 * Returns the list of annotators to be used in the classification model union
	 * technique during a training process.
	 * 
	 * @return	the list of annotators
	 */
	public List<String> getAnnotators() {
		return annotators;
	}
	
	/**
	 * Adds an annotator to the list of annotators to be used in the classification
	 * model union technique during a training process.
	 * 
	 * @param annotator	the annotator to add
	 */
	public void addAnnotator(String annotator){
		annotators.add(annotator);
	}
	
	private ClassificationModel trainingResult;
	private List<String> typesList = new ArrayList<String>();
	private String annotatorName;
	private String testingFile;
	private ClassificationModelCreator.MLTechnique machineLearningTechnique;
	private List<CharacterFeatureClassifier> featuresList = null;
	private List<String> UCompareFeaturesList = null;
	private int featuresWindow = 3;
    private int line;
    private int charPositionInLine=0;
    private int techniqueUsed = Etxt2DBGrammarParser.NOTECH;
    private String workflowFile;
    private int context = Etxt2DBGrammarParser.DOCUM;
    private String tokenizerName;
    private String regularExpression;
    private String regularExpressionType;
    private String dictionaryPath;
    private boolean dictionaryCase = true;
    private String machineLearningTrainingPath;
    private String beginTag;
    private String endTag;
    private boolean docPerFile;
    private List<String> annotators = new ArrayList<String>();
}
